﻿<UserControl x:Class="PrismInteractionLack.MainPage"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
			 xmlns:PrismInteractionLack="clr-namespace:PrismInteractionLack" mc:Ignorable="d"
			 MinWidth="500" MinHeight="500"
	d:DesignHeight="300" d:DesignWidth="400">

	<Grid x:Name="LayoutRoot" Background="White" Margin="20">
		<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
			<TextBlock TextWrapping="Wrap">
				<Bold>The Prism architecture lack for the Interactions!</Bold>
				<LineBreak/>
				(For the Silverlight.)
				<LineBreak/>
				<LineBreak/>
				The defect opens a popups more then once and creates memory leaks
				<LineBreak/>
				by making a strong reference to a thrown views through implicit event subscribtion.
				<LineBreak/>
				<LineBreak/>
				Workaround: Clean the DataContext on a control Unload event (For example by setting the DataContext to the null)
				<LineBreak/>
				<LineBreak/>
				Scenario: You have changeble Views for one ViewModel. You create new views for the same view model object.
			</TextBlock>
			
			<Button Content="Change current View in the visual tree (it has no sense)" Click="ChangeViewButtonClick" Margin="30" HorizontalAlignment="Center"/>
			
			<TextBlock TextWrapping="Wrap">
				<LineBreak/>
				<Bold>Example</Bold>
				<LineBreak/>
				At this example any click on the next three buttons will opens two popups.
				<LineBreak/>
				But if you check the "Apply the real workaround" checkbox,
				<LineBreak/>
				it will makes the expected behavior and only one popup will appears.
				<LineBreak/>
			</TextBlock>
			
			<StackPanel Orientation="Horizontal">
				<StackPanel.RenderTransform>
					<ScaleTransform ScaleX="2" ScaleY="2"/>
				</StackPanel.RenderTransform>
				
				<CheckBox
					x:Name="ApplyWorkaroundCheckBox"
					Click="ApplyWorkaroundCheckBoxClicked"
					ToolTipService.ToolTip="Apply the real workaround"
				/>
				<Grid Margin="1 0"/>
				<TextBlock>Apply the real workaround</TextBlock>
			</StackPanel>
			
			<ContentControl x:Name="ViewHolder"/>
			
		</StackPanel>
	</Grid>
</UserControl>
